package org.xtremeobjects.domain.associations;

import java.util.List;

import org.xtremeobjects.anotations.Image;
import org.xtremeobjects.anotations.Label;
import org.xtremeobjects.anotations.constraints.Pre;
import org.xtremeobjects.anotations.state.StateField;
import org.xtremeobjects.anotations.state.StateMachine;

import com.domainlanguage.time.TimePoint;

@StateMachine(initialState="Open")
public class Issue {
	
	@Label("Key")
	String key;
	
	@Label("Type")
	IssueDescription type;

	enum IssueStatus {
		@Image("Open.gif")
		Open,
		@Image("InProgress.gif")
		InProgress,
		@Image("Resolved.gif")
		Resolved,
		@Image("Reopened.gif")
		Reopened,
		@Image("Closed.gif")
		Closed
	}

	@Label("Status")
	@StateField
	IssueStatus status;
	
	@Label("Priority")
	IssuePriority priority;

	@Label("Assignee")
	Assignee assignee;

	@Label("Reporter")
	Reporter reporter;

	@Label("Votes")
	List<Vote> votes;
	
	@Label("Watchers")
	List<Watcher> watchers;

	@Label("Summary")
	String summary;
	
	@Label("Description")
	String description;

	@Label("Created")
	TimePoint createdOn;
	
	@Label("Updated")
	TimePoint updatedOn;
	
	@Label("Comments")
	List<Comment> comments;
	
	@Label("Due Date")
	TimePoint dueOn;
	
	@Label("Security Level")
	SecurityLevel securityLevel;
	
	
	String asXML() {
		return "XML";
	}
	
	String asWord() {
		return "Word";
	}
	
	@Label("Vote")
	@Pre(expr="context.me != self.assignee", message="You cannot vote for an issue you have reported") 
	void vote() {
	}
	
	void watch() {
	}
	
	@Label("Assign this issue")
	void assign() {
	}
	
	@Label("Clone this issue")
	void cloneIssue() {
	}
	
	@Label("Comment on this issue")
	void comment() {
	}
	
	@Label("Move this issue")
	void move() {
	}
	
	
}
